<include file="Public/min-header" />
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <include file="Public/breadcrumb" />
    <section class="content">
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 分销设置</h3>
                </div>
                <div class="panel-body ">
                    <!--                    <ul class="nav nav-tabs">
                                            <li class="active"><a href="#tab_tongyong" data-toggle="tab">申请用户</a></li>
                                        </ul>-->
                    <form method="post" id="handlepost" action="{:U('AppDistribut/set')}">
                        <div class="tab-content" style="padding:20px 0px;">
                            <div class="tab-pane active" id="tab_smtp">
                                <table class="table table-bordered">
                                    <tbody>
                                        <tr>
                                            <td class="col-sm-2 align-right">分销开关：</td>
                                            <td class="col-sm-6">
                                                开:<input type="radio" name="switch" value="1" <if condition="$config['switch'] eq 1">checked="checked"</if> /> 
                                    关:<input type="radio" name="switch" value="0" <if condition="$config['switch'] eq 0">checked="checked"</if> />
                                    </td>
                                    <td class="col-sm-7">{$config.desc}</td>
                                    </tr>
                                    <tr>
                                        <td class="col-sm-2 align-right">成为分销商条件：</td>
                                        <td class="col-sm-6">
                                            <!--                                    <input type="radio" name="condition" value="0" <if condition="$config[condition] eq 0">checked="checked"</if> /> 直接成为分销商 &nbsp;&nbsp;&nbsp;
                                                                                <input type="radio" name="condition" value="1" <if condition="$config[condition] eq 1">checked="checked"</if> /> 成功购买商品后成为分销商-->
                                            <input type="radio" name="condition" value="2" checked="checked" /> 后台直接设置
                                        </td>
                                        <td class="col-sm-7"></td>
                                    </tr>
                                    <tr>
                                        <td class="col-sm-2 align-right">分销名称：</td>
                                        <td class="col-sm-6">
                                            <input type="text" class="form-control" name="name" value="{$config.name}" />
                                        </td>
                                        <td class="col-sm-7">{$config.desc}</td>
                                    </tr>
                                    <tr>
                                        <td class = "align-right">分销模式：</td>
                                        <td>
                                            <!--<input type="radio" name="pattern" value="0" checked="checked" /> 按商品设置的分成金额-->
                                            <input type="radio" name="pattern" value="1" checked="checked" /> 按订单设置的分成比例
                                        </td>
                                    </tr>
                                    <!--                                    <tr id="distribut_order_rate" <if condition="$config['pattern'] eq 0">style="display:none"</if>>
                                                                        <td class="col-sm-2">订单默认分成比例：</td>
                                                                        <td class="col-sm-3">
                                                                            <input type="text" class="form-control" name="order_rate" value="{$config.order_rate}" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value = this.value.replace(/[^\d]/g, '')" />
                                                                        </td>
                                                                        <td class="col-sm-7">% {$config.desc}</td>
                                                                        </tr>-->
                                    <tr>
                                        <td class = "align-right">一级分销商名称：</td>
                                        <td>
                                            <input type="text" class="form-control" name="first_name" value="{$config.first_name}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class = "align-right">一级分销商比例：</td>
                                        <td>
                                            <input type="text" class="form-control" name="first_rate" id="distribut_first_rate" value="{$config.first_rate}" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value = this.value.replace(/[^\d]/g, '')">
                                        </td>
                                        <td class="col-sm-7">%</td>
                                    </tr>
                                    <tr>
                                        <td class = "align-right">二级分销商名称：</td>
                                        <td>
                                            <input type="text" class="form-control" name="second_name" value="{$config.second_name}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class = "align-right">二级分销商比例：</td>
                                        <td>
                                            <input type="text" class="form-control" name="second_rate" id="distribut_second_rate" value="{$config.second_rate}" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value = this.value.replace(/[^\d]/g, '')">
                                        </td>
                                        <td class="col-sm-7">%</td>
                                    </tr>
                                    <!--                                    <tr>
                                                                            <td>三级分销商名称：</td>
                                                                            <td>
                                                                                <input type="text" class="form-control" name="third_name" value="{$config.third_name}">
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td>三级分销商比例：</td>
                                                                            <td>
                                                                                <input type="text" class="form-control" name="third_rate" id="distribut_third_rate" value="{$config.third_rate}" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value = this.value.replace(/[^\d]/g, '')">
                                                                            </td>
                                                                            <td class="col-sm-7">%</td>
                                                                        </tr>-->
                                    <tr>
                                        <td class = "align-right">分成时间：</td>
                                        <td>
                                            <select class="form-control" name="date" id="distribut_date">
                                                <for start="1" end="31" name="i">
                                                    <option value="{$i}" <if condition="$config[date] eq $i">selected="selected"</if>>{$i}天</option>
                                                </for>
                                            </select>
                                        </td>
                                        <td class="col-sm-7">订单收货确认后多少天可以分成</td>
                                    </tr>
                                    <tr>
                                        <td class = "align-right">满多少才能提现：</td>
                                        <td>
                                            <input type="text" class="form-control" name="need" id="distribut_need" value="{$config.need}" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value = this.value.replace(/[^\d]/g, '')">
                                        </td>
                                        <td class="col-sm-7"></td>
                                    </tr>
                                    <tr>
                                        <td class = "align-right">最少提现额度：</td>
                                        <td>
                                            <input type="text" class="form-control" name="min" id="distribut_min" value="{$config.min}" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value = this.value.replace(/[^\d]/g, '')">
                                        </td>
                                        <td class="col-sm-7"></td>
                                    </tr>
                                     <tr>
                                        <td class = "align-right">推广二维码：</td>
                                        <td>
                                            <img src="/Public/upload/qrcode/qrcode_level_5.png"/>
                                        </td>
                                        <td class="col-sm-7"></td>
                                    </tr>
                                    </tbody>
                                    <tfoot>
                                        <tr>
                                            <td>
                                                <input type="hidden" name="inc_type" value="{$inc_type}">
                                            </td>
                                            <td class="text-right">
                                                <input class="btn btn-primary" type="button" onclick="adsubmit()" value="保存">
                                            </td>
                                        </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
</div>
<script>
    $('#distribut_pattern').change(function () {
        if ($(this).val() == 1)
            $('#distribut_order_rate').show();
        else
            $('#distribut_order_rate').hide();
    });

    function adsubmit() {
        var distribut_first_rate = $.trim($('#distribut_first_rate').val());
        var distribut_second_rate = $.trim($('#distribut_second_rate').val());
        var distribut_third_rate = $.trim($('#distribut_third_rate').val());

        var rate = parseInt(distribut_first_rate) + parseInt(distribut_second_rate) + parseInt(distribut_third_rate);
        if (rate > 100) {
            layer.msg('三个分销商比例总和不得超过100%', {
                icon: 2,
                time: 2000
            });
            return false;
        }

        $('#handlepost').submit();
    }

    $(document).ready(function () {
        get_province();
    });

    function goset(obj) {
        window.location.href = $(obj).attr('data-url');
    }
</script>
</body>

</html>
